Optimal. Leaf size=236 \[ \frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {(b c-a d)^2 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d^3 \left (c^2+d^2\right ) f}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.52, antiderivative size = 236, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 45, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.133, Rules used = {3728, 3718,
3707, 3698, 31, 3556} \begin {gather*} -\frac {\log (\cos (e+f x)) \left (a^2 (B c-d (A-C))+2 a b (A c+B d-c C)-b^2 (B c-d (A-C))\right )}{f \left (c^2+d^2\right )}+\frac {x \left (a^2 (A c+B d-c C)-2 a b (B c-d (A-C))-b^2 (A c+B d-c C)\right )}{c^2+d^2}+\frac {(b c-a d)^2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d^3 f \left (c^2+d^2\right )}-\frac {b \tan (e+f x) (-a C d-b B d+b c C)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 31
Rule 3556
Rule 3698
Rule 3707
Rule 3718
Rule 3728
Rubi steps
\begin {align*} \int \frac {(a+b \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx &=\frac {C (a+b \tan (e+f x))^2}{2 d f}+\frac {\int \frac {(a+b \tan (e+f x)) \left (-2 (b c C-a A d)+2 (A b+a B-b C) d \tan (e+f x)-2 (b c C-b B d-a C d) \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx}{2 d}\\ &=-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}-\frac {\int \frac {2 \left (2 a b c C d-a^2 A d^2-b^2 c (c C-B d)\right )-2 \left (a^2 B-b^2 B+2 a b (A-C)\right ) d^2 \tan (e+f x)-2 \left (a^2 C d^2-2 a b d (c C-B d)+b^2 \left (c^2 C-B c d+(A-C) d^2\right )\right ) \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{2 d^2}\\ &=\frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}+\frac {\left ((b c-a d)^2 \left (c^2 C-B c d+A d^2\right )\right ) \int \frac {1+\tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{d^2 \left (c^2+d^2\right )}+\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \int \tan (e+f x) \, dx}{c^2+d^2}\\ &=\frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}+\frac {\left ((b c-a d)^2 \left (c^2 C-B c d+A d^2\right )\right ) \text {Subst}\left (\int \frac {1}{c+x} \, dx,x,d \tan (e+f x)\right )}{d^3 \left (c^2+d^2\right ) f}\\ &=\frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {(b c-a d)^2 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d^3 \left (c^2+d^2\right ) f}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 1.92, size = 190, normalized size = 0.81 \begin {gather*} \frac {\frac {(a+i b)^2 (-i A+B+i C) d \log (i-\tan (e+f x))}{c+i d}+\frac {(a-i b)^2 (i A+B-i C) d \log (i+\tan (e+f x))}{c-i d}+\frac {2 (b c-a d)^2 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d^2 \left (c^2+d^2\right )}+\frac {2 b (-b c C+b B d+a C d) \tan (e+f x)}{d}+C (a+b \tan (e+f x))^2}{2 d f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.25, size = 317, normalized size = 1.34
method | result | size |
derivativedivides | \(\frac {\frac {b \left (\frac {C b d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+b \tan \left (f x +e \right ) B d +2 \tan \left (f x +e \right ) C a d -C b c \tan \left (f x +e \right )\right )}{d^{2}}+\frac {\left (A \,a^{2} d^{4}-2 A a b c \,d^{3}+A \,b^{2} c^{2} d^{2}-B \,a^{2} c \,d^{3}+2 B a b \,c^{2} d^{2}-B \,b^{2} c^{3} d +C \,a^{2} c^{2} d^{2}-2 C a b \,c^{3} d +C \,b^{2} c^{4}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{d^{3} \left (c^{2}+d^{2}\right )}+\frac {\frac {\left (-A \,a^{2} d +2 A a b c +A \,b^{2} d +B \,a^{2} c +2 B a b d -B \,b^{2} c +C \,a^{2} d -2 C a b c -C \,b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (A \,a^{2} c +2 A a b d -A \,b^{2} c +B \,a^{2} d -2 B a b c -B \,b^{2} d -C \,a^{2} c -2 C a b d +C \,b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}}{f}\) | \(317\) |
default | \(\frac {\frac {b \left (\frac {C b d \left (\tan ^{2}\left (f x +e \right )\right )}{2}+b \tan \left (f x +e \right ) B d +2 \tan \left (f x +e \right ) C a d -C b c \tan \left (f x +e \right )\right )}{d^{2}}+\frac {\left (A \,a^{2} d^{4}-2 A a b c \,d^{3}+A \,b^{2} c^{2} d^{2}-B \,a^{2} c \,d^{3}+2 B a b \,c^{2} d^{2}-B \,b^{2} c^{3} d +C \,a^{2} c^{2} d^{2}-2 C a b \,c^{3} d +C \,b^{2} c^{4}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{d^{3} \left (c^{2}+d^{2}\right )}+\frac {\frac {\left (-A \,a^{2} d +2 A a b c +A \,b^{2} d +B \,a^{2} c +2 B a b d -B \,b^{2} c +C \,a^{2} d -2 C a b c -C \,b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (A \,a^{2} c +2 A a b d -A \,b^{2} c +B \,a^{2} d -2 B a b c -B \,b^{2} d -C \,a^{2} c -2 C a b d +C \,b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}}{f}\) | \(317\) |
norman | \(\frac {\left (A \,a^{2} c +2 A a b d -A \,b^{2} c +B \,a^{2} d -2 B a b c -B \,b^{2} d -C \,a^{2} c -2 C a b d +C \,b^{2} c \right ) x}{c^{2}+d^{2}}+\frac {b \left (B b d +2 a C d -C b c \right ) \tan \left (f x +e \right )}{d^{2} f}+\frac {b^{2} C \left (\tan ^{2}\left (f x +e \right )\right )}{2 d f}+\frac {\left (A \,a^{2} d^{4}-2 A a b c \,d^{3}+A \,b^{2} c^{2} d^{2}-B \,a^{2} c \,d^{3}+2 B a b \,c^{2} d^{2}-B \,b^{2} c^{3} d +C \,a^{2} c^{2} d^{2}-2 C a b \,c^{3} d +C \,b^{2} c^{4}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d^{3} f}-\frac {\left (A \,a^{2} d -2 A a b c -A \,b^{2} d -B \,a^{2} c -2 B a b d +B \,b^{2} c -C \,a^{2} d +2 C a b c +C \,b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f \left (c^{2}+d^{2}\right )}\) | \(318\) |
risch | \(\text {Expression too large to display}\) | \(1458\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.54, size = 299, normalized size = 1.27 \begin {gather*} \frac {\frac {2 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {2 \, {\left (C b^{2} c^{4} + A a^{2} d^{4} - {\left (2 \, C a b + B b^{2}\right )} c^{3} d + {\left (C a^{2} + 2 \, B a b + A b^{2}\right )} c^{2} d^{2} - {\left (B a^{2} + 2 \, A a b\right )} c d^{3}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d^{3} + d^{5}} + \frac {{\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c - {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {C b^{2} d \tan \left (f x + e\right )^{2} - 2 \, {\left (C b^{2} c - {\left (2 \, C a b + B b^{2}\right )} d\right )} \tan \left (f x + e\right )}{d^{2}}}{2 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 6.80, size = 396, normalized size = 1.68 \begin {gather*} \frac {2 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c d^{3} + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d^{4}\right )} f x + {\left (C b^{2} c^{2} d^{2} + C b^{2} d^{4}\right )} \tan \left (f x + e\right )^{2} + {\left (C b^{2} c^{4} + A a^{2} d^{4} - {\left (2 \, C a b + B b^{2}\right )} c^{3} d + {\left (C a^{2} + 2 \, B a b + A b^{2}\right )} c^{2} d^{2} - {\left (B a^{2} + 2 \, A a b\right )} c d^{3}\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (C b^{2} c^{4} - {\left (2 \, C a b + B b^{2}\right )} c^{3} d + {\left (C a^{2} + 2 \, B a b + A b^{2}\right )} c^{2} d^{2} - {\left (2 \, C a b + B b^{2}\right )} c d^{3} + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d^{4}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) - 2 \, {\left (C b^{2} c^{3} d + C b^{2} c d^{3} - {\left (2 \, C a b + B b^{2}\right )} c^{2} d^{2} - {\left (2 \, C a b + B b^{2}\right )} d^{4}\right )} \tan \left (f x + e\right )}{2 \, {\left (c^{2} d^{3} + d^{5}\right )} f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [C] Result contains complex when optimal does not.
time = 2.68, size = 4444, normalized size = 18.83 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.83, size = 338, normalized size = 1.43 \begin {gather*} \frac {\frac {2 \, {\left (A a^{2} c - C a^{2} c - 2 \, B a b c - A b^{2} c + C b^{2} c + B a^{2} d + 2 \, A a b d - 2 \, C a b d - B b^{2} d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {{\left (B a^{2} c + 2 \, A a b c - 2 \, C a b c - B b^{2} c - A a^{2} d + C a^{2} d + 2 \, B a b d + A b^{2} d - C b^{2} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {2 \, {\left (C b^{2} c^{4} - 2 \, C a b c^{3} d - B b^{2} c^{3} d + C a^{2} c^{2} d^{2} + 2 \, B a b c^{2} d^{2} + A b^{2} c^{2} d^{2} - B a^{2} c d^{3} - 2 \, A a b c d^{3} + A a^{2} d^{4}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d^{3} + d^{5}} + \frac {C b^{2} d \tan \left (f x + e\right )^{2} - 2 \, C b^{2} c \tan \left (f x + e\right ) + 4 \, C a b d \tan \left (f x + e\right ) + 2 \, B b^{2} d \tan \left (f x + e\right )}{d^{2}}}{2 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 11.20, size = 325, normalized size = 1.38 \begin {gather*} \frac {\mathrm {tan}\left (e+f\,x\right )\,\left (\frac {B\,b^2+2\,C\,a\,b}{d}-\frac {C\,b^2\,c}{d^2}\right )}{f}+\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (d^2\,\left (C\,a^2\,c^2+2\,B\,a\,b\,c^2+A\,b^2\,c^2\right )-d\,\left (B\,b^2\,c^3+2\,C\,a\,b\,c^3\right )-d^3\,\left (B\,c\,a^2+2\,A\,b\,c\,a\right )+A\,a^2\,d^4+C\,b^2\,c^4\right )}{f\,\left (c^2\,d^3+d^5\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (A\,b^2-A\,a^2+B\,a^2\,1{}\mathrm {i}-B\,b^2\,1{}\mathrm {i}+C\,a^2-C\,b^2+A\,a\,b\,2{}\mathrm {i}+2\,B\,a\,b-C\,a\,b\,2{}\mathrm {i}\right )}{2\,f\,\left (d+c\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (B\,a^2-B\,b^2+2\,A\,a\,b-2\,C\,a\,b-A\,a^2\,1{}\mathrm {i}+A\,b^2\,1{}\mathrm {i}+C\,a^2\,1{}\mathrm {i}-C\,b^2\,1{}\mathrm {i}+B\,a\,b\,2{}\mathrm {i}\right )}{2\,f\,\left (c+d\,1{}\mathrm {i}\right )}+\frac {C\,b^2\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,d\,f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________